﻿

namespace Huirui.Cavan.Application.MainBoundedContext.SystemModule
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Huirui.Cavan.Domain.MainBoundedContext.SystemModule;
    using Huirui.Cavan.Domain.MainBoundedContext.SearchModule;
    using Huirui.Cavan.Application.MainBoundedContext.CacheModule;

    public class AreaAppService : BaseAppService<Area, string, AreaSearch, IAreaRepository>, IAreaAppService
    {
        [Cache(true, "Area")]
        public override IEnumerable<Area> GetBySearch(AreaSearch searchParams)
        {
            return base.GetBySearch(searchParams);
        }

        public  void InitAreaList()
        {
            if (Area.Provinces == null || Area.Provinces.Count == 0)
            {
                Area.Provinces = this.GetBySearch(SearchFactory.CreateAreaSearch(1)).OrderBy(r => r.Name).ToList();
                Area.Cities = this.GetBySearch(SearchFactory.CreateAreaSearch(2)).OrderBy(r => r.Name).ToList();
            }
        }


    }
}
